package concurrent;


import java.util.concurrent.ForkJoinPool;
import java.util.concurrent.RecursiveTask;

/**
 *
 */
public class ForkAndJoin {
    public static void main(String[] args) {

        CountTask task1 = new CountTask();
        CountTask task2 = new CountTask();
        ForkJoinPool pool = new ForkJoinPool();

        String s = pool.invoke(task1);

        String s1 = pool.invoke(task2);

        System.out.print(s+s1);
    }
}


class CountTask extends RecursiveTask<String> {

    private  String size;

    public String doSomeThing() {
        return size+"1";
    }

    @Override
    protected String compute() {
        return doSomeThing();
    }

}
